package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Mine;
import com.ruoyi.system.service.IMineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 矿山管理Controller
 * 
 * @author ruoyi
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/system/mine")
public class MineController extends BaseController
{
    @Autowired
    private IMineService mineService;

    /**
     * 查询矿山管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mine:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mine mine)
    {
        startPage();
        List<Mine> list = mineService.selectMineList(mine);
        return getDataTable(list);
    }

    /**
     * 导出矿山管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mine:export')")
    @Log(title = "矿山管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mine mine)
    {
        List<Mine> list = mineService.selectMineList(mine);
        ExcelUtil<Mine> util = new ExcelUtil<Mine>(Mine.class);
        util.exportExcel(response, list, "矿山管理数据");
    }

    /**
     * 获取矿山管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mine:query')")
    @GetMapping(value = "/{mineId}")
    public AjaxResult getInfo(@PathVariable("mineId") Long mineId)
    {
        return success(mineService.selectMineByMineId(mineId));
    }

    /**
     * 新增矿山管理
     */
    @PreAuthorize("@ss.hasPermi('system:mine:add')")
    @Log(title = "矿山管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mine mine)
    {
        return toAjax(mineService.insertMine(mine));
    }

    /**
     * 修改矿山管理
     */
    @PreAuthorize("@ss.hasPermi('system:mine:edit')")
    @Log(title = "矿山管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mine mine)
    {
        return toAjax(mineService.updateMine(mine));
    }

    /**
     * 删除矿山管理
     */
    @PreAuthorize("@ss.hasPermi('system:mine:remove')")
    @Log(title = "矿山管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mineIds}")
    public AjaxResult remove(@PathVariable Long[] mineIds)
    {
        return toAjax(mineService.deleteMineByMineIds(mineIds));
    }
}
